package com.livepass.android.girlspicks;

import java.util.HashMap;
import java.util.Map;

import android.app.Application;

public class MyApplication extends Application {
	public static String PACKAGE_NAME;
	public static String FOLDER_NAME;
	public static int API_VERSION;
	public static String APP_LINK_GLOBAL = "http://girlspicks.co/mobile/article.html?";
	public static String WHERE = "where"; //pushExtra when start PushCommentReplyActivity
	public static int COMMENT = 0;
	public static int REPLY = 1;
	public static Map<String,Integer> NUMBER_OF_PAGES = new HashMap<String, Integer>();
	public static String USER_ID = "1";
	public static String AP;
	public static Map<String, Boolean> IS_BOOKMARK = new DefaultHashMap<String, Boolean>(false);
	
	//private Context context;
	
	@Override
	public void onCreate() {
		super.onCreate();
		initVariables();
		initSingletons();
	}

	protected void initSingletons() {
		//TODO init Helpers
	}

	protected void initVariables() {
		//context = getApplicationContext();
		PACKAGE_NAME = getPackageName();
		API_VERSION = android.os.Build.VERSION.SDK_INT;
	}
	
	/**
     * overide HashMap has a default value
     * 
     * @author vuvt
     *
     * @param <K>
     * @param <V>
     */
    @SuppressWarnings("serial")
    private static class DefaultHashMap<K, V> extends HashMap<K, V> {
        protected V defaultValue;

        public DefaultHashMap(V defaultValue) {
            this.defaultValue = defaultValue;
        }

        @Override
        public V get(Object k) {
            V v = super.get(k);
            return ((v == null) && !this.containsKey(k)) ? this.defaultValue : v;
        }
    }
}